import os


class GameStats:
    """跟踪统计游戏信息"""

    def __init__(self, settings):
        self.settings = settings
        self.reset_stats()
        # 游戏状态，初始化为非活动状态，当点击开始是才开始游戏
        self.game_active = False
        # 最高得分
        if not os.path.exists("config.ini"):
            self.high_score = 0
        else:
            with open("config.ini") as f:
                self.high_score = int(f.read())

    def reset_stats(self):
        # 每次游戏开始得分重置
        self.score = 0
        # 剩余飞船数目
        self.ship_left = self.settings.ship_limit
        # 游戏等级
        self.level = 1
